package com.wyg.service.impl;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import com.wyg.dao.QuestionDao;
import com.wyg.dao.UserDao;
import com.wyg.dao.impl.QuestionDaoImpl;
import com.wyg.dao.impl.UserDaoImpl;
import com.wyg.pojo.Question;
import com.wyg.service.ManagerService;

public class ManagerServiceImpl implements ManagerService {
	private HttpServletRequest request;
	private HttpServletResponse response;
	private UserDao udi;
	private QuestionDao qdi;
	
	public UserDao getUdi() {
		return udi;
	}

	public void setUdi(UserDao udi) {
		this.udi = udi;
	}

	public QuestionDao getQdi() {
		return qdi;
	}

	public void setQdi(QuestionDao qdi) {
		this.qdi = qdi;
	}

	@Override
	public String showAllUser() {
		List list = udi.findAllUser();
		this.request = ServletActionContext.getRequest();
		request.setAttribute("list", list);
		return "showAllUser";
	}

	@Override
	public void findPage() {
	}

	@Override
	public String allChoiceQuestion() {
		List list = qdi.showChoiceQuestion();
		this.request = ServletActionContext.getRequest();
		request.setAttribute("questions", list);
		
		return "showChoiceQuestion";
	}

	@Override
	public String showOnLineUser() {
		return "showOnLineUser";
	}

	@Override
	public String showPanduanQuestion() {
		List list = qdi.showPanduanQuestion();
		this.request = ServletActionContext.getRequest();
		request.setAttribute("questions", list);
		return "showPanduanQuestion";
	}

	@Override
	public String goChangeQuestion() {
		this.request = ServletActionContext.getRequest();
		int id =Integer.valueOf( request.getParameter("qid"));
		Question q = qdi.showOneQuestion(id);
		request.setAttribute("question", q);
		return "goChangeQuestion";
	}

}
